

<script>
import { userProfileget } from "@/api/index.js";
export default {
  onLaunch: function() {
    // plus.screen.lockOrientation("portrait-primary");
    if (!uni.getStorageSync("cacheList")) {
      uni.setStorageSync("cacheList", []);
    } else {
      let cacheList = uni.getStorageSync("cacheList");
      let arr = [];
      uni.getSavedFileList({
        success: function(res) {
          cacheList.forEach((item, index) => {
            if (res.fileList.some(val => val.filePath === item.cachePath)) {
              arr.push(item);
            }
          });
          uni.setStorageSync("cacheList", arr);
        }
      });
    }
    // console.log("App Launch11111111111111111111111111111111");
    // let videoList = uni.getStorageSync("videoList");
    // let cacheList = [];
    // //手机中已经下载的视频
    // uni.getSavedFileList({
    //   success: function(res) {
    //     cacheList = res.fileList;
    //   }
    // });
    //  console.log(111111111111)

    let tok = uni.getStorageSync("token");

    if (tok) {
      userProfileget().then(res => {
        if (res.data.code != 401) {
          //  uni.reLaunch({
          //           url: "/pages/preview/preview"
          //         });
          let roleKey = uni.getStorageSync("roleKey");
          if (roleKey === "Installer") {
            uni.reLaunch({
              url: "/pages/video/index"
            });
          } else {
            uni.reLaunch({
              url: "/pages/preview/preview?"
            });
          }
        }
      });
    } else {
      uni.removeStorageSync("token");
      uni.removeStorageSync("roleKey");
      uni.reLaunch({
        url: "/pages/login/login"
      });
    }
  },
  onShow: function() {
  },
  onHide: function() {
  }
};
</script>

<style lang="scss">
/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
@import "uview-ui/index.scss";
/*每个页面公共css */
@import "./style/uni.css";
/**上传样式 */
@import "./style/detail.scss";

/*每个页面公共css */
page {
  height: 100%;
  background-color: white;
}

.content {
  background: #f4f5f7;
  min-height: 100%;
  box-sizing: border-box;
  padding-bottom: 200rpx;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  color: rgb(78, 78, 78);
  font-family: "宋体", "微软雅黑", "Arial";
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
</style>
